package com.manli.api.controller;

import java.util.Arrays;
import java.util.Map;

import com.manli.api.pojo.QueryParamsQiniuFile;
import com.manli.api.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.manli.api.base.annotation.Permissions;
import com.manli.api.pojo.QueryParams;
import com.manli.api.dto.AQiniuFiles;
import com.manli.api.service.AQiniuFilesService;



/**
 * 七牛上传文件信息
 *
 * @author manli
 * @email 
 * @date 2020-06-18 13:10:21
 */
@Api(value="/aqiniufiles", tags="七牛上传文件信息")
@RestController
@RequestMapping("api/aqiniufiles")
public class AQiniuFilesController {
    @Autowired
    private AQiniuFilesService aQiniuFilesService;

    /**
     * 列表
     */
    @ApiOperation(value = "七牛上传文件信息列表",notes = "")
    @PostMapping("/list")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result list(@RequestBody QueryParamsQiniuFile params){
        return aQiniuFilesService.queryPage(params);
    }

    /**
     * 保存
     */
    @ApiOperation(value = "七牛上传文件信息保存",notes = "七牛上传文件信息保存")
    @PostMapping("/save")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result save(@RequestBody AQiniuFiles aQiniuFiles){
        return aQiniuFilesService.save(aQiniuFiles);
    }

    /**
     * 修改
     */
    @ApiOperation(value = "七牛上传文件信息修改",notes = "七牛上传文件信息修改")
    @PostMapping("/update")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result update(@RequestBody AQiniuFiles aQiniuFiles){
        return aQiniuFilesService.updateById(aQiniuFiles);
    }


    /**
     * 删除多条数据
     */
    @ApiOperation(value = "七牛上传文件信息删除",notes = "七牛上传文件信息删除")
    @ApiImplicitParam(name = "ids", value = "id数组,json字符串",dataType = "id数组,json字符串", required = true)
    @PostMapping("/deleteIds")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result deleteIds(@RequestBody Integer[] ids){
        return aQiniuFilesService.removeByIds(Arrays.asList(ids));
    }

    /**
     * 删除多条数据by file name
     */
    @ApiOperation(value = "七牛上传文件信息删除by file name",notes = "七牛上传文件信息删除by file name")
    @ApiImplicitParam(name = "names", value = "name数组,json字符串",dataType = "name数组,json字符串", required = true)
    @PostMapping("/deleteByNames")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result deleteByNames(@RequestBody String[] names)throws Exception{
        return aQiniuFilesService.deleteByNames(Arrays.asList(names));
    }

}
